#!/usr/bin/sh

if [ $# -eq 5 ]; then

    NODE="$1"
    SCRIPT="prj2server.erl"
    NODES=$2
    FILES=$3
    REP=$4
    MACHINES=$5
    NEIGHBORS=0
elif [ $# -eq 6 ]; then
    NODE="$1"
    SCRIPT="prj2server.erl"
    NODES=$2
    FILES=$3
    REP=$4
    MACHINES=$5
    NEIGHBORS=$6
else
    echo "Usage: sh launch.sh <erlang node name> <nodes> <files> <rep> <machines> [neighbors]"
    exit 1
fi


echo "$NODES $FILES $REP $MACHINES"
echo "c(average). c(median). c(gossipprob). c(prj2server). c(db). c(fileupdate). c(fileretrieve). c(prj2). c(gossipMin). c(gossipMax). prj2:init($NODES, $FILES, $REP, $MACHINES, $NEIGHBORS). q()." | erl -name ${NODE}
